/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.mpower.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.mpower.model.Author;
import com.mpower.model.AuthorModel;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

/**
 * The base model implementation for the Author service. Represents a row in the &quot;LIB_Author&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.mpower.model.AuthorModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AuthorImpl}.
 * </p>
 *
 * <p>
 * Never modify or reference this class directly. All methods that expect a author model instance should use the {@link com.mpower.model.Author} interface instead.
 * </p>
 *
 * @author gavin
 * @see AuthorImpl
 * @see com.mpower.model.Author
 * @see com.mpower.model.AuthorModel
 * @generated
 */
public class AuthorModelImpl extends BaseModelImpl<Author>
	implements AuthorModel {
	public static final String TABLE_NAME = "LIB_Author";
	public static final Object[][] TABLE_COLUMNS = {
			{ "authorId", new Integer(Types.BIGINT) },
			{ "authorName", new Integer(Types.VARCHAR) }
		};
	public static final String TABLE_SQL_CREATE = "create table LIB_Author (authorId LONG not null primary key,authorName VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table LIB_Author";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.mpower.model.Author"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.mpower.model.Author"),
			true);
	public static final String MAPPING_TABLE_LIB_BOOK_AUTHOR_NAME = com.mpower.model.impl.BookModelImpl.MAPPING_TABLE_LIB_BOOK_AUTHOR_NAME;
	public static final boolean FINDER_CACHE_ENABLED_LIB_BOOK_AUTHOR = com.mpower.model.impl.BookModelImpl.FINDER_CACHE_ENABLED_LIB_BOOK_AUTHOR;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.mpower.model.Author"));

	public AuthorModelImpl() {
	}

	public long getPrimaryKey() {
		return _authorId;
	}

	public void setPrimaryKey(long pk) {
		setAuthorId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_authorId);
	}

	public long getAuthorId() {
		return _authorId;
	}

	public void setAuthorId(long authorId) {
		_authorId = authorId;
	}

	public String getAuthorName() {
		if (_authorName == null) {
			return StringPool.BLANK;
		}
		else {
			return _authorName;
		}
	}

	public void setAuthorName(String authorName) {
		_authorName = authorName;
	}

	public Author toEscapedModel() {
		if (isEscapedModel()) {
			return (Author)this;
		}
		else {
			return (Author)Proxy.newProxyInstance(Author.class.getClassLoader(),
				new Class[] { Author.class }, new AutoEscapeBeanHandler(this));
		}
	}

	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					Author.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	public Object clone() {
		AuthorImpl clone = new AuthorImpl();

		clone.setAuthorId(getAuthorId());
		clone.setAuthorName(getAuthorName());

		return clone;
	}

	public int compareTo(Author author) {
		long pk = author.getPrimaryKey();

		if (getPrimaryKey() < pk) {
			return -1;
		}
		else if (getPrimaryKey() > pk) {
			return 1;
		}
		else {
			return 0;
		}
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Author author = null;

		try {
			author = (Author)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = author.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(5);

		sb.append("{authorId=");
		sb.append(getAuthorId());
		sb.append(", authorName=");
		sb.append(getAuthorName());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(10);

		sb.append("<model><model-name>");
		sb.append("com.mpower.model.Author");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>authorId</column-name><column-value><![CDATA[");
		sb.append(getAuthorId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>authorName</column-name><column-value><![CDATA[");
		sb.append(getAuthorName());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _authorId;
	private String _authorName;
	private transient ExpandoBridge _expandoBridge;
}